package org.problem7.ccc2009p5;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Calendar;


public class BestWifiScannerApp
{
    
    public static void main(String args[]) throws Exception
    {
        FileReader fr = new FileReader(new File("src/main/resources/s5.5.in"));
        BufferedReader br = new BufferedReader(fr);
        String eastWest = br.readLine();
        String northSouth = br.readLine();
        String wifiCafes = br.readLine();
        BestWifiCalculator wifiCalc = new BestWifiCalculator();
        wifiCalc.setCityDimensions(Integer.valueOf(eastWest), Integer.valueOf(northSouth));
        int cafes = Integer.valueOf(wifiCafes);
        for ( int i = 0; i < cafes; i++ )
        {
            System.out.println("***************************************************");
            System.out.println("time:" + Calendar.getInstance().getTimeInMillis());
            System.out.println("inputting cafe #: " + i);
            String cafe = br.readLine();
            System.out.println("\tcafe data: " + cafe);
            String[] cafeData = cafe.split(" ");
            wifiCalc.addCafe(Integer.valueOf(cafeData[1]),Integer.valueOf(cafeData[0]),Integer.valueOf(cafeData[2]),Integer.valueOf(cafeData[3]));
        }
        //System.out.println("cafe map:");
        //System.out.println(wifiCalc.toString());
        System.out.println("OptimalBitrate: " + wifiCalc.optimalBitRate());
        System.out.println("total Cafes: " + wifiCalc.numberOfIntersectionWithOptimalBitRate());
        br.close();
        fr.close();
    }
}
